package UseFile;

import java.io.File;
import java.io.IOException;
import java.util.Arrays;

public class StructureFile {
    public static void main(String[] args) throws IOException {
        //getMessage();
        //mkdirDeleteFile();
        iterationFile();
    }
    public static void whetherExist(){
        File file = new File("/Users/wukai/Project/self_project/java_practice/8.内置模块/UseFile");
        boolean directory = file.isDirectory();
        boolean file1 = file.isFile();
        boolean exists = file.exists();
        System.out.println(directory);
        System.out.println(file1);
        System.out.println(exists);
    }

    public static void getMessage(){
        File file = new File("8.内置模块/UseFile/demo");
        // 获取文件、文件夹名称
        String name = file.getName();
        System.out.println(name);
        // 获取文件大小,字节大小
        long length = file.length();
        System.out.println(length);
        // 获取文件的最后修改时间,时间戳单位
        long l = file.lastModified();
        System.out.println(l);
        // 获取文件绝对路径
        File absoluteFile = file.getAbsoluteFile();
        System.out.println(absoluteFile);
        // 获取文件使用路径
        String path = file.getPath();
        System.out.println(path);

    }
    public static void mkdirDeleteFile() throws IOException {
        // 操作文件
        File file = new File("./8.内置模块/Kiwi/study.txt");
//        boolean mkdirs = file.mkdirs();
//        System.out.println(mkdirs);
        boolean newFile = file.createNewFile();
        System.out.println(newFile);



    }
    public static void iterationFile(){
        File[] files = File.listRoots();
        System.out.println(Arrays.toString(files));
    }

}
